package com.video.runlog;

import com.video.service.IRunLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

@Component
public class InitApplication implements CommandLineRunner {

    @Autowired
    private IRunLogService runLogService;

    /**
     * SpringBoot容器启动触发
     * @param args
     * @throws Exception
     */
    @Override
    public void run(String... args) throws Exception {

        //判断索引库是否存在
        if(!runLogService.isExistIndex()){
            //如果索引不存在，就创建索引库
            boolean flag = runLogService.createIndex();
            System.out.println("索引存在结果：" + flag);
        }

    }
}
